package com.langshixiaobai.admin.common.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


//可以通过 FilterRegistrationBean 将过滤器注册到 Spring Boot 应用中，这样过滤器也会由 Spring 管理。
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<UserTransmitFilter> myFilterRegistrationBean(UserTransmitFilter myFilter) {

        FilterRegistrationBean<UserTransmitFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(myFilter);
        registrationBean.addUrlPatterns("/*");
        registrationBean.setOrder(0); // 设置过滤器的顺序
        return registrationBean;
    }
}